package com.example.demo.leetcode;

import java.util.ArrayList;

/**
 * 链接：<a href="https://leetcode.cn/problems/bitwise-and-of-numbers-range/?envType=study-plan-v2&envId=top-interview-150">https://leetcode.cn/problems/bitwise-and-of-numbers-range/?envType=study-plan-v2&envId=top-interview-150</a>
 *
 * @author WangYX
 * @version 1.0.0
 * @date 2024/02/20 10:41
 */
public class _201_数据范围按位与 {

    public static void main(String[] args) {
        int i = rangeBitwiseAnd(5, 7);
        System.out.println(i);
    }

    public static int rangeBitwiseAnd(int left, int right) {
        int res = left;
        for (int i = left + 1; i <= right; i++) {
            System.out.println(i);
            res &= i;
        }
        return res;
    }
}
